package com.javakc.copyrightin.bookList.listener;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.javakc.copyrightin.bookList.entity.BookList;
import com.javakc.copyrightin.bookList.service.BookListService;
import com.javakc.copyrightin.bookList.vo.BookListData;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.CrossOrigin;

public class BookListListener extends AnalysisEventListener<BookListData> {

    private BookListService bookListService;

    public BookListListener() {

    }

    public BookListListener(BookListService bookListService) {
        this.bookListService = bookListService;
    }

    @Override
    public void invoke(BookListData bookListData, AnalysisContext context) {
        // ## 创建Book实体
        BookList bookList = new BookList();
        BeanUtils.copyProperties(bookListData, bookList);
        // ## 保存
        bookListService.saveOrUpdate(bookList);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {

    }
}